(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/script/LevelInfor.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '1aa45b7XgdPC7WMRt1HEoOZ', 'LevelInfor', __filename);
// script/LevelInfor.js

'use strict';

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad: function onLoad() {},
    start: function start() {
        var name = this.node.name;
        this.type = name.split('_')[1];
    },

    /**
     * 初始化
     */
    initInfor: function initInfor() {
        var name = this.node.parent.name;
        this.type = name.split('_')[1];
        var information = this.node.getChildByName("information");
        //左上角金币数量
        var coin = this.node.getChildByName("guileftup").getChildByName("New Label");
        this.coin = coin.getComponent(cc.Label);
        this.coin.string = cc.vv.CoinCount + " / " + cc.vv.CoinTotal;
        //右上角的死亡次数
        var death = this.node.getChildByName("guirightdown").getChildByName("New Label");
        this.death = death.getComponent(cc.Label);
        this.death.string = "X " + cc.vv.DeathNum;

        //过关后的弹框
        this.information = this.node.getChildByName("information");
        var coinTotal = this.information.getChildByName("coin");
        this.coinTotalTxt = coinTotal.getComponent(cc.Label);
        this.coinTotalTxt.string = cc.vv.CoinCount + " / " + cc.vv.CoinTotal;
        cc.vv["stageCoin" + this.type] = cc.vv.CoinCount;
        //弹框死亡次数
        var deathTxt = information.getChildByName("death");
        this.deathTxt = deathTxt.getComponent(cc.Label);
        this.deathTxt.string = "X " + cc.vv.DeathNum;
        cc.vv["stageDeath" + this.type] = cc.vv.DeathNum;
        if (cc.vv["stageCoin" + this.type] > cc.sys.localStorage.getItem('stageCoin' + this.type)) {
            //将数据保存至本地
            cc.sys.localStorage.setItem('stageCoin' + this.type, cc.vv["stageCoin" + this.type]);
            cc.sys.localStorage.setItem('stageDeath' + this.type, cc.vv["stageDeath" + this.type]);
        }
    },


    /**
     * 返回菜单
     */
    backMenu: function backMenu() {
        cc.director.loadScene("selectLevel");
    },


    /**
    * 重玩本关
    */
    reStart: function reStart() {
        var name = this.node.getChildByName("guirightup").children[0].getComponent(cc.Sprite).spriteFrame.name;
        var type = name.split('_')[1];
        cc.director.loadScene("stage" + type);
    },


    /**
    * 下一关
    */
    nextLevel: function nextLevel() {
        var name = this.node.getChildByName("guirightup").children[0].getComponent(cc.Sprite).spriteFrame.name;
        var type = name.split('_')[1];
        cc.director.loadScene("stage" + (parseInt(type) + 1));
    },
    update: function update(dt) {
        this.initInfor();
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=LevelInfor.js.map
        